<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gallery_model extends CI_Model
{
	// Get all images and their paths, filename etc
	public function get_all_images()
	{
		$this->db->order_by("galleryId", "asc");
		
		$query = $this->db->get('gallery');
		
		if($query->num_rows() > 0)
		{
			return $query->result_array();
		}
		return null;
	}
	
	// Save uploaded image to database from CI image object
	public function save_image_path($imgInfo)
	{
		$data = array(
			'fileName' => $imgInfo['file_name'],
			'fileType' => $imgInfo['file_type'],
			'filePath' => $imgInfo['file_path'],
			'fullPath' => $imgInfo['full_path'],
			'fileExt'  => $imgInfo['file_ext'],
			'imageWidth' => $imgInfo['image_width'],
			'imageHeight' => $imgInfo['image_height'],
			'imageSizeStr' => $imgInfo['image_size_str']);
		$this->db->insert('gallery',$data);
	}
}